import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_massage/common_lib/index.dart';
import 'package:flutter_massage/common_lib/utils/method_channel.dart';
import 'package:flutter_massage/service/index.dart';

class StorageKey {
  static const String allowUseApp = 'storage_key_allow_use_app';
  static const String userKey = 'storage_key_user_login';
  static const String nameKey = 'storage_key_name';
  static const String avatarKey = 'storage_key_avatar';
}

class ConstantValues {
  static final ConstantValues _instance = ConstantValues._internal();

  factory ConstantValues() => _instance;

  ConstantValues._internal();

  String deviceToken = '';

  static String get client => Platform.isAndroid ? 'android' : 'iPhone';

  static Future<String> get device async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    if (Platform.isAndroid) {
      return (await deviceInfo.androidInfo).device;
    } else {
      return (await deviceInfo.iosInfo).utsname.machine ?? '';
    }
  }

  static Future<String> get appName async => await PackageInfoUtils().getAppName();

  static String get idfa => XydUserService.idfa;

  static Future<String> get version async => await PackageInfoUtils().getVersion();

  static Future<String> get tdid async => await XydMethodChannel.getTdid();
}
